/**
 * Copyright ©2016-2020 tianyu education Corporation, All Rights Reserved
 * http://www.whty.com.cn/
 */
package profile.hujia.profile.elasticsearch.study.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import profile.hujia.profile.elasticsearch.study.service.IndexService;

import java.io.IOException;

/**
 * class info
 *
 * @author hujia
 * @date 2019-09-04 14:14
 */
@RestController
@RequestMapping
@Slf4j
public class IndexController {
    @Autowired
    private IndexService indexService;

    @PutMapping("/indexAdd")
    public void crateIndex(String indexName){
        try {
            indexService.createIndex(indexName);
        }catch (IOException e){
            log.error("error"+e);
        }
    }

    @PutMapping("/indexDelete")
    public void deleteIndex(String indexName){
        try {
            indexService.deleteIndex(indexName);
        }catch (IOException e){
            log.error("error"+e);
        }
    }
}
